<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>猜数字游戏</title>
</head>
<body>
    <h1>猜数字游戏</h1>
    <p>请输入一个数字:</p>
    <input type="number" id="guessInput">
    <button id="guessButton">猜</button>
    <p id="result"></p>

    <script>
        const targetNumber = Math.floor(Math.random() * 100) + 1;

        document.getElementById('guessButton').addEventListener('click', function() {
            const guess = parseInt(document.getElementById('guessInput').value);
            const result = document.getElementById('result');

            if (guess < targetNumber) {
                result.textContent = '猜小了!';
            } else if (guess > targetNumber) {
                result.textContent = '猜大了!';
            } else {
                result.textContent = '恭喜你，猜中了!';
            }
        });
    </script>
</body>
</html>
